from rest_framework.response import Response as _
from base_utils.response_http_code import SuccessStatus
from .response_fmt import get_response_dict


class Response(_):
    """
    自定义统一格式响应类
    格式：
    {
        "code": int,
        "msg": str,
        "data": Any | None,
    }
    """

    def __init__(
        self,
        code: int = SuccessStatus.http_code,  # 自定义状态码
        msg: str = SuccessStatus.msg,
        data=None,
        status=None,  # 请求状态码
        headers=None,
        **kwargs
    ):
        # 标准化响应体
        response_data = get_response_dict(code, msg, data, **kwargs)
        super().__init__(data=response_data, status=status, headers=headers)
